<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>百度地图API - 周边搜索</title>
<!-- 引入地图api -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2">
</script>
</head>
<body>

<div style="width:1080px;height:960px;border:1px solid gray" id="container">
</div>

<script type="text/javascript">

//创建地图
var map = new BMap.Map("container");

//初始化并定位
map.centerAndZoom("北京");

//加载导航控件
var opts = {type: BMAP_NAVIGATION_CONTROL_SMALL}
map.addControl(new BMap.NavigationControl(opts));

//新增周边搜索
var local = new BMap.LocalSearch(map, {
  renderOptions: {
    map: map,
    autoViewport: true
  }
});

map.addEventListener("load", function(){
  //搜索
  local.searchNearby("五道口", "北京");
});
</script>
</body>
</html>
